package com.wuzheng.common.obs.upload.config;

import com.obs.services.ObsConfiguration;
import com.wuzheng.common.obs.upload.service.ObsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Title: ObsConfig
 * Description: 自动注入obsService上传工具类
 * @author hfl
 * @version V1.0
 * @date 2020-05-27
 */
@Configuration
@EnableConfigurationProperties(ObsProperties.class)
public class ObsConfig {

    @Autowired
    private ObsProperties obsProperties;

    @Bean
    public ObsService obsService(){
        ObsConfiguration config = new ObsConfiguration();
        config.setSocketTimeout(30000);
        config.setConnectionTimeout(10000);
        config.setEndPoint(obsProperties.getEndPoint());
        return new ObsService(obsProperties.getBucketName(), obsProperties.getBucketLoc(), config);
    }

}
